package com.dnjn.happiness.common.config.ext.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;

@Slf4j
public class BaseMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {

        setFieldValByName("deleted", "0", metaObject);
        setFieldValByName("createTime", LocalDateTime.now(), metaObject);

        setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
    }


    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
    }



}
